package com.zsp.coupon.filter;

import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;

import javax.servlet.http.HttpServletRequest;

public class AccessLogFilter extends AbstactPreZuulFilter{
    @Override
    protected Object cRun() {
        HttpServletRequest request=content.getRequest();
        // 从 PreRequestFilter 中获取设置的请求时间戳
          Long startTime=(Long) content.get("startTime");
              String uri=  request.getRequestURI();
        long duration = System.currentTimeMillis();
        // 从网关通过的请求都会打印日志记录: uri + duration
        System.out.println("uri duration;{}"+uri+":"+duration);
        return success();
    }

    @Override
    public int filterOrder() {
        return FilterConstants.SEND_RESPONSE_FILTER_ORDER -1;

    }
}
